package com.pinapel.aixml.ui.menuBar;

import java.awt.event.ActionEvent;

import javax.swing.JMenu;

import com.pinapel.aixml.controller.MenuController;

import com.pinapel.aixml.controller.Menu.IMenuViewController;
import com.pinapel.aixml.tools.i18n.I18n;
import com.pinapel.aixml.tools.log.EnumMessageType;
import com.pinapel.aixml.tools.log.Logger;

public class MenuView extends JMenu{
    private javax.swing.JMenuItem jMenuViewTextMode;
    private javax.swing.JMenuItem jMenuViewGraphMode;
    private javax.swing.JMenuItem jMenuViewSemantic;
    private javax.swing.JMenuItem jMenuViewXMLSchema;
    private javax.swing.JMenuItem jMenuViewToolsBar;
    private IMenuViewController mController;
    boolean hide;
    
    public MenuView(){
        jMenuViewTextMode = new javax.swing.JMenuItem();
        jMenuViewGraphMode = new javax.swing.JMenuItem();
        jMenuViewSemantic = new javax.swing.JMenuItem();
        jMenuViewXMLSchema = new javax.swing.JMenuItem();
        jMenuViewToolsBar = new javax.swing.JMenuItem();
        hide=false;
        this.setText(I18n.getString(I18n.UI017_VIEW));

        jMenuViewTextMode.setText(I18n.getString(I18n.UI001_TEXT_MODE));
        jMenuViewTextMode.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuViewTextModeActionPerformed(evt);
            }
        });
        this.add(jMenuViewTextMode);

        jMenuViewGraphMode.setText(I18n.getString(I18n.UI002_GRAPHIC_MODE));
        jMenuViewGraphMode.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuViewGraphModeActionPerformed(evt);
            }
        });
        this.add(jMenuViewGraphMode);

        jMenuViewSemantic.setText(I18n.getString(I18n.UI004_SEMANTIC));
        this.add(jMenuViewSemantic);
        jMenuViewSemantic.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuViewSemanticModeActionPerformed(evt);
            }
        });

        jMenuViewXMLSchema.setText(I18n.getString(I18n.UI020_XML_SCHEMA));
        this.add(jMenuViewXMLSchema);
        jMenuViewXMLSchema.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuViewSchemaModeActionPerformed(evt);
            }
        });
        jMenuViewToolsBar.setText(I18n.getString(I18n.UI019_TOOLBAR));
        this.add(jMenuViewToolsBar);
        jMenuViewToolsBar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuViewToolsBarActionPerformed(evt);
            }
        });
        
    }
    public void setController(IMenuViewController c){
    	mController = c;
    }
    /**                  **/
    /** TABS ORDER       **/
    /** 0 = Text Tab     **/
    /** 1 = Graph Tab    **/
    /** 2 = Schema Tab   **/
    /** 3 = Semantic Tab **/
    private void jMenuViewTextModeActionPerformed(ActionEvent evt) {
		mController.getMainController().setEditorsUI(0);
		
	}
    private void jMenuViewGraphModeActionPerformed(ActionEvent evt) {
		mController.getMainController().setEditorsUI(1);
		
	}
    private void jMenuViewSchemaModeActionPerformed(ActionEvent evt) {
		mController.getMainController().setEditorsUI(2);
		
	}
    private void jMenuViewSemanticModeActionPerformed(ActionEvent evt) {
		mController.getMainController().setEditorsUI(3);
		
		
	}
    private void jMenuViewToolsBarActionPerformed(ActionEvent evt) {
		mController.getMainController().getButtonsController().hideButtons(hide);
		if (hide){
			Logger.addMessage(EnumMessageType.INFO, I18n.getString(I18n.LG018_SHOW_BUTTONS_BAR));
		}
		else{
			Logger.addMessage(EnumMessageType.INFO, I18n.getString(I18n.LG019_HIDE_BUTTONS_BAR));
		}
		hide=!hide;
	}
}
